/*

 Copyright (C) 2010 Tiago Matos Santos <tiagoms88 AT gmail DOT com>
   
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Library General Public License as
 published by the Free Software Foundation; either version 2 of the
 License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this program; if not, write to the
 Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
*/

#ifndef _PROGRAMA_H_

#define _PROGRAMA_H_

#include <QMainWindow>
#include <QThread>
#include <ui_JanelaPrograma.h>
#include <ui_DialogoSobre.h>
#include <ui_DialogoComunicacao.h>
#include "serial/qextserialport.h"

class ReceberThread : public QThread
{
    Q_OBJECT

  public:
    ReceberThread(QObject* parent = 0);
    virtual ~ReceberThread();

  public: // From QThread
    void run();

//  signals:
//    void dataChanged();

//  public slots:
//    void setData(int someData);

//  private:
//    int data;
};

class ModeloPortaSerial {
  private:

  public:
    ModeloPortaSerial(QString porta, BaudRateType velocidade);
    ~ModeloPortaSerial();

    void resetaPortaSerial();
    
    BaudRateType velocidade;
    DataBitsType bitsDados;
    ParityType paridade;
    StopBitsType bitsParada;
    FlowType controleFluxo;
    QString porta;

    QextSerialPort *portaSerial;
};

class ConfigComunicacao : public QDialog, private Ui::DialogoComunicacao
{
	Q_OBJECT
	
  private:
	ModeloPortaSerial *modelPort;

  public:
	ConfigComunicacao(QWidget *parent = 0);

  public slots:
    void actionAtualizarConfigPorta();

};

class MainWindow : public QMainWindow, public Ui::MainWindow
{
	Q_OBJECT
 
  private:
    ConfigComunicacao *cfgCom;
    ReceberThread receberThread;

  public:
	MainWindow();
    ~MainWindow();
    ModeloPortaSerial *modelPorta;

  public slots:
	void on_actionSair_triggered();
	void on_actionSobre_triggered();
	void on_actionComunicacao_triggered();
	void actionEnviar();
    void actionReceber();
    void actionStatus();

};

class Sobre : public QDialog, private Ui::DialogoSobre
{	
	Q_OBJECT

  public:
	Sobre(QWidget *parent = 0);

  public slots:

};

#endif
